<template>
  <view style="border-radius: 10rpx;">
    <view class="home-quota">
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_uncomplete') }}</view>
        <view class="home-quota__item-value">{{ data.unComplete || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_yesterday') }}</view>
        <view class="home-quota__item-value">{{ data.yestodayComplete  || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_all_complete') }}</view>
        <view class="home-quota__item-value">{{ data.allComplete  || '0'}}</view>
      </view>
    </view>
    <view class="home-quota">
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_three_days') }}</view>
        <view class="home-quota__item-value">{{ data.threeDays || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_seven_days') }}</view>
        <view class="home-quota__item-value">{{ data.sevenDays  || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('home_quota_fifteen_days') }}</view>
        <view class="home-quota__item-value">{{ data.fiftyDays  || '0'}}</view>
      </view>
    </view>
    <view class="home-quota">
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('delivery_today') }}</view>
        <view class="home-quota__item-value">{{ deliveryData.todaySubmitted || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('delivery_uncompleted') }}</view>
        <view class="home-quota__item-value">{{ deliveryData.uncompleted  || '0' }}</view>
      </view>
      <view class="home-quota__item">
        <view class="home-quota__item-label">{{ translate('delivery_total') }}</view>
        <view class="home-quota__item-value">{{ deliveryData.total  || '0'}}</view>
      </view>
    </view>
  </view>
</template>

<script>
// 导入语言文件
import zhLang from '@/utils/zh.js';
import enLang from '@/utils/en.js';
import storage from "@huntianning/miniprogram/utils/storage";

export default {
  name: 'HomeQuota',
  data() {
    return {
      currentLocale: 'zh', // 默认语言
      // 语言包
      languages: {
        'zh': zhLang,
        'en': enLang
      }
    }
  },
  mounted() {
    // 初始化语言
    let savedLanguage = uni.getStorageSync('language') || 'zh';
    const currentTimeType = storage.get('CURRENT_TIME_TYPE');
    savedLanguage=(currentTimeType === 1 || currentTimeType === '1') ? 'en' : 'zh';
    this.currentLocale = savedLanguage;
  },
  methods: {
    // 翻译函数 - 与 order-delivery 页面保持一致
    translate(key) {
      try {
        const langPack = this.languages[this.currentLocale] || this.languages['zh'];
        return langPack[key] || key;
      } catch (e) {
        console.error('Translation error:', e);
        return key;
      }
    }
  },
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    deliveryData: {
      type: Object,
      default: () => ({})
    }
  }
}
</script>

<style>
.home-quota{
  margin:  0rpx  20rpx;
  display: flex;
  flex-direction: row;
  background-color: #fff;
  padding: 8rpx 8rpx 5rpx;
}
.home-quota__item {
  flex: 1;
  min-width: 0;
  padding: 6px 12rpx;
}
.home-quota__item-label{
  text-align: center;
  font-weight: bolder;
  color: #666666;
  height: 30rpx;
  line-height: 30rpx;
  margin-bottom: 8rpx;
  font-size: 26rpx;
}
.home-quota__item-value{
  padding-top: 8rpx;
  text-align: center;
  font-size: 23rpx;
  font-weight: bold;
  color: #F47554;
}
</style>
